package cn.dengta.webapp.trade.model;

import cn.dengta.common.model.ValueProxy;
import cn.dengta.common.model.ValueProxyImpl;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

@Getter
public enum Side implements ValueProxyImpl<Side, Integer> {
	/** from */
	FROM(1, "from"),
	/** to */
	TO(2, "to");

	@EnumValue
	public final Integer value;
	final ValueProxy<Side, Integer> proxy;

	// 构造函数，枚举类型只能为私有
	Side(Integer value, String label) {
		this.value = value;
		this.proxy = new ValueProxy<>(this, value, label);
	}

	public static Side[] getValues() {
		return ValueProxy.getCachedArray(Side.class, Side::values);
	}

	public static Side of(Integer value) {
		return FROM.getValueOf(value);
	}

	public static Side of(boolean fromOrTo) {
		return fromOrTo ? FROM : TO;
	}

}
